import pandas as pd
import json

def tracks2json():
    tracks = pd.read_excel('./tracks.xlsx')
    # get tracks.iloc[1:116, 1] as region, tracks.iloc[1:116, 2] as track, tracks.iloc[1:116, 3] as length to array of dict
    tracks_json = []
    for i in range(1, 116):
        tracks_json.append({
            'region': tracks.iloc[i, 1],
            'name': tracks.iloc[i, 2],
            'length': float(tracks.iloc[i, 3])
        })
    
    # write to tracks.json
    with open('./tracks.json', 'w') as f:
        json.dump(tracks_json, f, indent=4, ensure_ascii=False)

tracks2json()